<template>
	<view class="toolPage">
		<view class="flex-colume-start tool-bg" style="min-height: 100vh;">
			<view style="height: 20rpx;"></view>

			<view class="goodsBox" v-for="(item,index) in dataArr" :key="index">
				<view class="title1">{{item.name}}</view>
				<view class="box11">
					<view @click="goodsItemClick(item1)" class="flex-colume-start goodsItem" v-for="(item1, index1) in item.sons" :key="index1">
						<image :src="item1.thumb_url" class="img1"></image>
						<view class="text-one-line t1">{{item1.name}}</view>
						<view class="flex-row-start price-box">
							<view class="price1">
								<span style="font-size: 20rpx;">¥</span>
								{{item1.shop_price}}
								<span class="word2">{{item1.buy_count}}人已购买</span>
								
							</view>
							<view class="b22">立即购买</view>
							
							
						</view>

					</view>

				</view>
			</view>
			
			<view style="height: 40rpx;"></view>
			<view style="height: calc(env(safe-area-inset-bottom) + 49px);"></view>

		</view>
		<custom-tab-bar :selected="1"></custom-tab-bar>
	</view>
</template>

<script>
	import {goodsIndex} from '@/api/api.js'
	export default {
		data() {
			return {
				dataArr: []

			}
		},
		onLoad(){
			goodsIndex().then(res=>{
				if (res.code == 200){
					this.dataArr = res.data
					
				}
			})
		},
		methods: {
			centerBtnClick() {
				uni.switchTab({
					url: '/pages/tab/center'
				})

			},
			goodsItemClick(item1){
				uni.navigateTo({
					url:'/pages/goods/goodsDetail?goodsId='+item1.id
				})
			}

		}
	}
</script>

<style lang="scss">
	.tool-bg {
		width: 750rpx;
		// height: 519rpx;
		background: url('https://app.yiheshuyuan.cn/static/weixin/xcxPic/mine-bg1.png');
		background-size: 100% 519rpx;
		background-repeat: no-repeat;
	}

	.goodsBox {
		.title1 {
			width: 100%;
			line-height: 80rpx;
			text-align: center;
			font-family: Source Han Sans CN;
			font-weight: bold;
			font-size: 42rpx;
			color: #38383A;
		}

		.box11 {
			width: 100vw;
			padding-left: 30rpx;
		}

		.goodsItem {
			float: left;
			font-size: 0rpx;
			width: 340rpx;
			
			background-color: white;
			margin-bottom: 10rpx;
			margin-left: 5rpx;
			margin-right: 5rpx;
			border-radius: 16rpx;
			overflow: hidden;
			
			.img1{
				width: 100%;
				height: 340rpx;
				border-radius: 16rpx;
				background-color: rgb(230, 230, 230);
			}
			.t1{
				margin-top: 20rpx;
				margin-left: 10rpx;
				width: calc(100% - 20rpx);
				text-align: left;
				
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 25rpx;
				color: #38383A;
				
			}
			.price-box{
				width: 100%;
				height: 40rpx;
				padding: 0rpx 10rpx;
				box-sizing: border-box;
				margin-top: 10rpx;
				margin-bottom: 18rpx;
				position: relative;
				.b22{
					position: absolute;
					font-size: 20rpx;
					height: 32rpx;
					line-height: 32rpx;
					border-radius: 4rpx;
					
					top: 4rpx;
					right: 8rpx;
					color: white;
					padding: 0rpx 8rpx;
					box-sizing: border-box;
					background-color: #C90000;
					
				}
			}
			.price1{
				font-family: HarmonyOS Sans SC;
				font-weight: 500;
				font-size: 35rpx;
				color: #C90000;
				.word2{
					margin-left: 5rpx;
					font-size: 22rpx;
					font-weight: normal;
					color: rgb(153, 153, 153);
				}
			}
		}
	}
</style>